//
//  LZDealCell.m
//  tuangou
//
//  Created by quan jimmy on 11-12-11.
//  Copyright 2011年 tencent. All rights reserved.
//

#import "LZDealCell.h"
#import <QuartzCore/CALayer.h>


@implementation LZDealCell
@synthesize discountLable,deal,priceLable,titleLable,dateLable,distinctLable,dealImageView;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        titleLable = [[UILabel alloc] initWithFrame:CGRectMake(100, 0, 200, 60)];
        titleLable.font = [UIFont systemFontOfSize: 14]; 
        titleLable.textColor = [UIColor colorWithRed:51.0/255 green:51.0/255 blue:51.0/255 alpha:1.0];
        titleLable.numberOfLines = 3;
        [self.contentView addSubview:titleLable];
        
        priceLable = [[UILabel alloc] initWithFrame:CGRectMake(100, 65, 50, 10)];
        priceLable.font = [UIFont systemFontOfSize: 12]; 
        priceLable.textColor = [UIColor colorWithRed:51.0/255 green:51.0/255 blue:51.0/255 alpha:1.0];
        [self.contentView addSubview:priceLable];
        
        discountLable = [[UILabel alloc] initWithFrame:CGRectMake(160, 65, 50, 10)];
        discountLable.font = [UIFont systemFontOfSize: 12]; 
        discountLable.textColor = [UIColor colorWithRed:51.0/255 green:51.0/255 blue:51.0/255 alpha:1.0];
        [self.contentView addSubview:discountLable];
        
        dealImageView = [[EGOImageView alloc] initWithPlaceholderImage:[UIImage imageNamed:@"articlePlaceHolder.png"]];
        dealImageView.frame = CGRectMake(10.0, 10.0, 80.0, 65.0);
        dealImageView.imageURL = [NSURL URLWithString: deal.deal_url];
        dealImageView.layer.shadowOpacity = 0.3;
        dealImageView.layer.shadowOffset = CGSizeMake(1, 1);
        [self.contentView addSubview:dealImageView];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void) setDeal:(Deal *)aDeal
{
	if (aDeal!=deal&&aDeal) {
		[aDeal retain];
		[deal release];
		deal=aDeal;
        
        titleLable.text = deal.deal_title;
        priceLable.text = [NSString stringWithFormat:@"%.1f¥",deal.price];
        discountLable.text = [NSString stringWithFormat:@"%.1f折",deal.rebate];
        
                dealImageView.imageURL = nil;
                dealImageView.placeholderImage = [UIImage imageNamed:@"imagePlaceHolder.png"];
                if (deal.deal_img) {
                    dealImageView.imageURL = [NSURL URLWithString: deal.deal_img];
                }
    }
}

- (void)dealloc
{
    [super dealloc];
}

@end
